package com.sap.tpcd.policybuilder.policymodel ;

/**
 * @author I068988
 * @version 1.0
 * @created 30-sept.-2011 14:12:34
 */
public class Authorisation extends Policy {

	private PolicyElement action;
	private boolean permitDeny;
	private PolicyElement ressource;
	private PolicyElement subject;

	public Authorisation(){
		super();
	}
	
	

	public Authorisation(PolicyElement action, boolean permitDeny,
			PolicyElement ressource, PolicyElement subject) {
		super();
		this.action = action;
		this.permitDeny = permitDeny;
		this.ressource = ressource;
		this.subject = subject;
	}

	
	/* (non-Javadoc)
	 * @see com.sap.tpcd.policyhandler.Policy#getPolicyName()
	 */
	@Override
	public String getPolicyName() {
		// TODO Auto-generated method stub
		return super.getPolicyName();
	}



	/* (non-Javadoc)
	 * @see com.sap.tpcd.policyhandler.Policy#setPolicyName(java.lang.String)
	 */
	@Override
	public void setPolicyName(String policyName) {
		// TODO Auto-generated method stub
		super.setPolicyName(policyName);
	}



	/* (non-Javadoc)
	 * @see com.sap.tpcd.policyhandler.Policy#getM_PolicyElement()
	 */
	@Override
	public PolicyElement getM_PolicyElement() {
		// TODO Auto-generated method stub
		return super.getM_PolicyElement();
	}



	/* (non-Javadoc)
	 * @see com.sap.tpcd.policyhandler.Policy#setM_PolicyElement(com.sap.tpcd.policyhandler.PolicyElement)
	 */
	@Override
	public void setM_PolicyElement(PolicyElement m_PolicyElement) {
		// TODO Auto-generated method stub
		super.setM_PolicyElement(m_PolicyElement);
	}



	/**
	 * @return the action
	 */
	public PolicyElement getAction() {
		return action;
	}



	/**
	 * @param action the action to set
	 */
	public void setAction(PolicyElement action) {
		this.action = action;
	}



	/**
	 * @return the permitDeny
	 */
	public boolean isPermitDeny() {
		return permitDeny;
	}



	/**
	 * @param permitDeny the permitDeny to set
	 */
	public void setPermitDeny(boolean permitDeny) {
		this.permitDeny = permitDeny;
	}



	/**
	 * @return the ressource
	 */
	public PolicyElement getRessource() {
		return ressource;
	}



	/**
	 * @param ressource the ressource to set
	 */
	public void setRessource(PolicyElement ressource) {
		this.ressource = ressource;
	}



	/**
	 * @return the subject
	 */
	public PolicyElement getSubject() {
		return subject;
	}



	/**
	 * @param subject the subject to set
	 */
	public void setSubject(PolicyElement subject) {
		this.subject = subject;
	}



	/* (non-Javadoc)
	 * @see java.lang.Object#hashCode()
	 */
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = super.hashCode();
		result = prime * result + ((action == null) ? 0 : action.hashCode());
		result = prime * result + (permitDeny ? 1231 : 1237);
		result = prime * result
				+ ((ressource == null) ? 0 : ressource.hashCode());
		result = prime * result + ((subject == null) ? 0 : subject.hashCode());
		return result;
	}



	/* (non-Javadoc)
	 * @see java.lang.Object#equals(java.lang.Object)
	 */
	@Override
	public boolean equals(Object obj) {
		if (this == obj) {
			return true;
		}
		if (!super.equals(obj)) {
			return false;
		}
		if (!(obj instanceof Authorisation)) {
			return false;
		}
		Authorisation other = (Authorisation) obj;
		if (action == null) {
			if (other.action != null) {
				return false;
			}
		} else if (!action.equals(other.action)) {
			return false;
		}
		if (permitDeny != other.permitDeny) {
			return false;
		}
		if (ressource == null) {
			if (other.ressource != null) {
				return false;
			}
		} else if (!ressource.equals(other.ressource)) {
			return false;
		}
		if (subject == null) {
			if (other.subject != null) {
				return false;
			}
		} else if (!subject.equals(other.subject)) {
			return false;
		}
		return true;
	}



	
}